<?xml version="1.0" encoding="ISO-8859-1" ?>
 
<html xmlns="http://www.w3.org/1999/xhtml" 
	  xmlns:h="http://java.sun.com/jsf/html" 
	  xmlns:f="http://java.sun.com/jsf/core"
	  xmlns:c="http://java.sun.com/jsp/jstl/core"
	  xmlns:p="http://primefaces.org/ui"
	  xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head></h:head> 
	<h:body> 
		<ui:composition template="/template.xhtml">
			<ui:define name="conteudo">
			
			<center>
				<h:form id="form">
					<p:outputLabel value="#{msg.alunos}"/>  	
						<p:inputText id="query" label="query" value="#{alunoManagedBean.query}"  /> 		            
			           	<p:commandButton value="#{msg.pesquisar}" action="#{alunoManagedBean.listarAlunos}" 
			           					 update="alunoTable" style="font-size: 16px; margin-left: 10px;" 
			           					 styleClass="btn" />
			           	
			           	<p:dataTable id="alunoTable" var="aluno" value="#{alunoManagedBean.alunos}"  >	  			
			  			
						    <f:facet name="header">  
						        	<p:column colspan="2">				  			
						        		<h:outputText value="#{msg.alunos}" />
						        	</p:column>
						    </f:facet>  
						  	
							  	<p:column headerText="#{msg.nome}" >
							  		<h:outputLabel value="#{aluno.nome}" /> 
							  	</p:column>
							  	
							  	<p:column headerText="#{msg.qtdWarns}" >
							  		<h:outputLabel value="#{aluno.usuario.qtdWarns}" /> 
							  	</p:column>
							  							  	
							  	<p:column headerText="#{msg.acao}" >
									<h:commandLink actionListener="#{usuarioManagedBean.adicionaWarns}" rendered="#{aluno.usuario.qtdWarns!=7}">
										<f:attribute name="usuario" value="#{aluno.usuario}"/>
										<h:graphicImage value="/img/soma.png" title="#{msg.adicionarWarns}" style="border: none" />
									</h:commandLink>
									
									<h:commandLink actionListener="#{usuarioManagedBean.subtraiWarns}" rendered="#{aluno.usuario.qtdWarns!=0}">
										<f:attribute name="usuario" value="#{aluno.usuario}"/>
										<h:graphicImage value="/img/subtracao.png" title="#{msg.subtrairWarns}" style="border: none" />
									</h:commandLink>	
									
									<h:commandLink actionListener="#{usuarioManagedBean.limpaWarns}">
										<f:attribute name="usuario" value="#{aluno.usuario}"/>
										<h:graphicImage value="/img/lixo.png" title="#{msg.limparWarns}" style="border: none" />
									</h:commandLink>
																										
							  	</p:column>		
							  	
							  	<p:column headerText="#{msg.dataAcesso}" >
							  		<center>
							  			<h:outputLabel value="#{aluno.usuario.dataAcesso!=null?aluno.usuario.dataAcesso
							  			:(aluno.usuario.dataAcesso==null and aluno.usuario.qtdWarns!=7 ?'Acessso Liberado'
							  			:(aluno.usuario.dataAcesso==null and aluno.usuario.qtdWarns==7 ? 'banido'
							  			:' '))}" >
							  				<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="#{initParam.timezone}" />
							  			</h:outputLabel> 
							  		</center>
							  	</p:column>	    
						</p:dataTable>
										
			  	</h:form>
			</center>
			
			</ui:define>
		</ui:composition>
	</h:body> 
</html>
